package net.mingsoft.basic.interceptor;

import org.springframework.web.servlet.handler.*;
import org.springframework.beans.factory.annotation.*;
import javax.servlet.http.*;
import net.mingsoft.basic.util.*;
import net.mingsoft.basic.entity.*;

public class ActionInterceptor extends HandlerInterceptorAdapter
{
    @Value("${ms.manager.path}")
    private String managerPath;
    
    public boolean preHandle(final HttpServletRequest request, final HttpServletResponse response, final Object handler) {
        final String base = request.getScheme() + "://" + request.getServerName() + ((request.getServerPort() == 80) ? "" : (":" + request.getServerPort()));
        final String contextPath = request.getServletContext().getContextPath();
        request.setAttribute("base", (Object)contextPath);
        final AppEntity app = BasicUtil.getWebsiteApp();
        if (app == null) {
            request.setAttribute("app", (Object)BasicUtil.getApp());
        }
        else {
            request.setAttribute("app", (Object)app);
        }
        request.setAttribute("managerPath", (Object)(contextPath + this.managerPath));
        request.setAttribute("params", (Object)BasicUtil.assemblyRequestUrlParams());
        return true;
    }
}
